package com.mydemo.springlearning.functions.DI.controller;

import com.mydemo.springlearning.common.entity.ServerResponse;
import com.mydemo.springlearning.functions.DI.po.ProvidedCar;
import com.mydemo.springlearning.functions.DI.po.ProvidedFruit;
import com.mydemo.springlearning.functions.access_limit.annotation.AccessLimit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("DI")
@Slf4j
public class DependencyInjectionController {

    ProvidedCar car;
    ProvidedFruit fruit;

    DependencyInjectionController(ProvidedCar car) {
        this.car = car;
    }

    @Autowired
    public void setFruit(ProvidedFruit fruit) {
        this.fruit = fruit;
    }

    @RequestMapping("test")
    public ServerResponse accessLimit() {
        System.out.println(car);
        System.out.println(fruit);
        return ServerResponse.success("依赖注入测试");
    }


}
